Fix missing parent document type specification in hasChild query example #2900
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
1、This pull request addresses an issue in the Spring Data Elasticsearch documentation where the specification of the parent document type is missing in the example code for the hasChild query.
2、The Routing property in the Statement class is incorrectly typed as Routing, when it should be String according to the context.
3、In the example code, there is a typo where a comma is used instead of a period: .withText("+1 for the sun") ,withRouting(savedWeather.getId()), where it should be .withText("+1 for the sun").withRouting(savedWeather.getId()).
In Elasticsearch 8.x, it's essential to specify the parent document type when using the hasChild query. Failure to specify the parent type results in an error from Elasticsearch. This pull request adds the missing .type("answer") statement to ensure the correct behavior of the query.
Changes Made:
Added .type("answer") statement to specify the parent document type in the hasChild query.
Updated the example code to reflect the correct usage of the hasChild query.
References:
Elasticsearch Documentation: has_child query
ClientVersion:
elastic-search-java :8.10.4
Excption:
co.elastic.clients.util.MissingRequiredPropertyException: Missing required property 'HasChildQuery.type'
at co.elastic.clients.util.ApiTypeHelper.requireNonNull(ApiTypeHelper.java:76)
at co.elastic.clients.elasticsearch._types.query_dsl.HasChildQuery.(HasChildQuery.java:82)
at co.elastic.clients.elasticsearch._types.query_dsl.HasChildQuery.(HasChildQuery.java:51)
at co.elastic.clients.elasticsearch._types.query_dsl.HasChildQuery$Builder.build(HasChildQuery.java:349)
at co.elastic.clients.elasticsearch._types.query_dsl.HasChildQuery$Builder.build(HasChildQuery.java:216)
at co.elastic.clients.elasticsearch._types.query_dsl.Query$Builder.hasChild(Query.java:1412)